var number = 3;
var startingPage;
//获取传递过来的值
var url = decodeURI(window.location.href);
var aa = url.indexOf('=');
if (aa > -1) {
    url = url.substring(aa + 1);
}

//通知
function inform_list() {
    startingPage = 0;
    var data = {
        "page": startingPage,
        "number": number
    };
    $.ajax({
        url: "findInformByInformList",
        type: "POST",
        dataType: "json",
        data: JSON.stringify(data),
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            var code = ' ';
            for (var i = 0; i < data.inform_List.length; i++) {
                code += "<li><a href=web-single-inform.html?id=" + data.inform_List[i].inform_id + ">" + data.inform_List[i].inform_title + "</a></li>";
            }
            $("#inform_1").append(code);

        }
    });
}

//废品公司初始数据
function loadWebList() {
    var data = {
        "recProductID": url
    };
    $.ajax({
        url: "findWebRecycleProductByRecProductID",
        type: "POST",
        dataType: "json",
        data: JSON.stringify(data),
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            var code = ' ';
            var Data = '';
            if (data.code == 500) {
                Swal.fire("提示", "查询数据失败", "error");
            } else {
                for (var i = 0; i < data.product_List.length; i++) {
                    code += "  <div class=\"item-img-gallery\">\n" +
                        "                                    <div class=\"tab-content\">\n" +
                        "                                        <div class=\"tab-pane fade show active\" id=\"gallery1\" role=\"tabpanel\">\n" +
                        "                                            <a href=\"#\">\n" +
                        "                                                <img class=\"zoom_01\" style='width: 820px;height: 420px;' src='upload/" + data.product_List[0].recProductImage + "'\n" +
                        "                                                     alt=\"product\"\n" +
                        "                                                     data-zoom-image='upload/" + data.product_List[0].recProductImage + "'>\n" +
                        "                                            </a>\n" +
                        "                                        </div>\n" +
                        "                                    </div>\n" +
                        "                                </div>\n" +
                        "                                <div class=\"single-entry-meta\">\n" +
                        "                                    <ul>\n" +
                        "                                        <li><i class=\"far fa-clock\"></i>" + data.product_List[0].recProductDate + "</li>\n" +
                        "                                        <li><i class=\"fas fa-map-marker-alt\"></i>" + data.product_List[0].companyEntity.compAddress + "</li>\n" +
                        "                                        <li><i class=\"far fa-eye\"></i>220 view</li>\n" +
                        "                                    </ul>\n" +
                        "                                </div>\n" +
                        "                                <div class=\"item-price\">\n" +
                        "                                    <span class=\"currency-symbol\">$</span>\n" +
                        "                                    " + data.product_List[0].recProductPrice + "<span>/</span>\n" +
                        "                                    " + data.product_List[0].recProductUnit + "\n" +
                        "                                </div>\n" +
                        "                                <div class=\"item-details-2\">\n" +
                        "                                    <div class=\"row\">\n" +
                        "                                        <div class=\"col-lg-8\">\n" +
                        "                                            <div class=\"left-side-content\">\n" +
                        "                                                <p> " + data.product_List[0].recProductDetail + "</p>\n" +
                        "                                            </div>\n" +
                        "                                        </div>\n" +
                        "                                    </div>\n" +
                        "                                </div>\n" +
                        "                                <div class=\"item-features\">\n" +
                        "                                    <h3 class=\"item-title\">商铺图片</h3>\n" +
                        "                                    <div class=\"row\">\n" +
                        "                                        <div class=\"col-md-12\">\n" +
                        "                                            <ul class=\"item-list\">\n" +
                        "                                                <li><img style='width: 820px;height: 400px' src='upload/" + data.product_List[0].companyEntity.compPhoto + "'></li>\n" +
                        "                                            </ul>\n" +
                        "                                        </div>\n" +
                        "                                    </div>\n" +
                        "                                    <div class=\"row\">\n" +
                        "                                        <div class=\"col-md-12\">\n" +
                        "                                            <ul class=\"item-list\">\n" +
                        "                                                <li><img style='width: 820px;height: 400px' src='upload/" + data.product_List[0].companyEntity.compBusinessLicense + "'></li>\n" +
                        "                                            </ul>\n" +
                        "                                        </div>\n" +
                        "                                    </div>\n" +
                        "                                </div>";

                    Data += " <div class=\"widget-lg widget-author-info widget-light-bg\">\n" +
                        "                        <h3 class=\"widget-border-title\">商铺信息</h3>\n" +
                        "                        <div class=\"author-content\">\n" +
                        "                            <div class=\"author-meta\">\n" +
                        "                                <ul>\n" +
                        "                                    <li><i class=\"fas fa-map-marker-alt\"></i>" + data.product_List[0].companyEntity.compAddress + "</li>\n" +
                        "                                    <li><i class=\"fas fa-shopping-basket\"></i><a href=\"store-detail.html\">" + data.product_List[0].recStyleEntity.recStyName + "</a>\n" +
                        "                                    </li>\n" +
                        "                                </ul>\n" +
                        "                            </div>\n" +
                        "                            <div class=\"phone-number classima-phone-reveal not-revealed\" data-phone=\"6735568568\">\n" +
                        "                                <div class=\"number\"><i class=\"fas fa-phone\"></i><span>" + data.product_List[0].companyEntity.compPhone + "</span></div>\n" +
                        "                                <div class=\"item-text\">Click to reveal phone number</div>\n" +
                        "                            </div>\n" +
                        "                            <div class=\"author-mail\">\n" +
                        "                                <a href=\"#\" class=\"mail-btn\" data-toggle=\"modal\" data-target=\"#author-mail\">\n" +
                        "                                    <i class=\"fas fa-envelope\"></i>" + data.product_List[0].companyEntity.compEmail + "\n" +
                        "                                </a>\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"widget-lg widget-safty-tip widget-light-bg\">\n" +
                        "                        <h3 class=\"widget-border-title\">最新通告</h3>\n" +
                        "                        <div class=\"safty-tip-content\">\n" +
                        "                            <ul id='inform_1'>\n" +
                        "                            </ul>\n" +
                        "                        </div>\n" +
                        "                    </div>\n";
                }
                $("#data_1").append(code);
                $("#data_2").append(Data);
            }
        }
    });
}

//废品类型
function Product_list() {
    startingPage = 0;
    var data = {
        "page": startingPage,
        "number": 4,
        "recProductID": url
    };
    $.ajax({
        url: "findWebRecycleProductByRecycleProductListByRecStyle",
        type: "POST",
        dataType: "json",
        data: JSON.stringify(data),
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            var code = ' ';
            for (var i = 0; i < data.product_List.length; i++) {
                code += "<div class=\"col-lg-3 col-md-6 col-sm-12\" >\n" +
                    "                    <div class=\"product-box-layout1\">\n" +
                    "                        <div class=\"item-img\" >\n" +
                    "                            <a  href=web-single-product.html?id=" + data.product_List[i].recProductID + "><img style='width: 300px;height: 200px;' src='upload/" + data.product_List[i].recProductImage + "' alt=\"Product\"></a>\n" +
                    "                        </div>\n" +
                    "                        <div class=\"item-content\">\n" +
                    "                            <h3 class=\"item-title\" ><a href=web-single-product.html?id=" + data.product_List[i].recProductID + ">" + data.product_List[i].recProductName + "</a>\n" +
                    "                            </h3>\n" +
                    "                            <ul class=\"entry-meta\" >\n" +
                    "                                <li><i class=\"far fa-clock\" ></i>" + data.product_List[i].recProductDate + "</li>\n" +
                    "                                <li><i class=\"fas fa-map-marker-alt\" ></i>" + data.product_List[i].companyEntity.compAddress + "</li>\n" +
                    "                            </ul>\n" +
                    "                            <div class=\"item-price\" >\n" +
                    "                                <span class=\"currency-symbol\">$</span>\n" +
                    "                               " + data.product_List[i].recProductPrice + "<span>/</span>\n" +
                    "                               " + data.product_List[i].recProductUnit + " \n" +
                    "                            </div>\n" +
                    "                        </div>\n" +
                    "                    </div>\n" +
                    "                </div>";
            }

            $("#product_2").append(code);

        }
    });
}


$(function () {
    var DATA = '';
    $.ajax({
        url: "JudgeLogin_3",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            if (data.code == 500) {
                DATA += " <li class=\"header-btn\">\n" +
                    "                                    <a href=\"web-login.html\" class=\"item-btn\"><i class=\"fas fa-plus\"></i>登录</a>\n" +
                    "                                </li>"
                Swal.fire("温馨提示", "请先登录", "warning");
                window.location.href = "web-user-404.html";
            } else {
                DATA += " <li class=\"header-login-icon\">\n" +
                    "                                    <a href=\"web-user-account.html\" class=\"color-light\" data-toggle=\"tooltip\"\n" +
                    "                                       data-placement=\"top\" title=\"Login/Register\">\n" +
                    "                                        <i class=\"far fa-user\">我的</i>\n" +
                    "                                    </a>\n" +
                    "                                </li>\n" +
                    "                                <li class=\"header-btn\">\n" +
                    "                                    <a  onclick='tuichu_1()' class=\"item-btn\"><i class=\"fas fa-plus\"></i>退出</a>\n" +
                    "                                </li>";
                loadWebList();
                setTimeout("inform_list()", 100);
                setTimeout("Product_list()", 400);
            }
            $("#userData").html("");
            $("#userData").append(DATA);
        }
    });
})